﻿using System;
using System.Windows.Forms;

namespace DotNetBurner.SubmitBot
{
    public partial class SubmitBotForm : Form
    {
        public SubmitBotForm()
        {
            InitializeComponent();
        }

        private void btnProcess_Click(object sender, EventArgs e)
        {
            string[] urls = txtFeeds.Text.Split(new string[] { Environment.NewLine }, 
                                                StringSplitOptions.RemoveEmptyEntries);

            FormLog logger = new FormLog();
            logger.MessageReceived += logger_MessageReceived;

            FeedProcessor processor = new FeedProcessor(urls, txtCachePath.Text, txtConnStr.Text, txtSubmitUser.Text, txtSiteUrl.Text,
                                                        txtPageGlimpseKey.Text, txtSiteName.Text, txtTrackback.Text, chkSendTrackBack.Checked,
                                                        chkAutoPublish.Checked, logger);
            processor.Process();
        }

        void logger_MessageReceived(object sender, MessageEventArgs e)
        {
            Invoke(new MethodInvoker(() => { toolStripStatusLabel1.Text = e.Message; }));
        }
    }
}
